package com.atguigu.paymentdemo.controller;

import com.atguigu.paymentdemo.entity.CourseFile;
import com.atguigu.paymentdemo.service.CourseFileService;
import com.atguigu.paymentdemo.util.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @author wulifeng
 */
@Api(tags = "课程文件表Controller")
@RestController
@RequestMapping("courseFile")
@AllArgsConstructor
public class CourseFileController {

	private final CourseFileService courseFileService;

	/**
	 * 新增课程文件
	 *
	 * @param courseFile 课程文件
	 * @return R
	 */
	@ApiOperation(value = "新增课程文件")
	@PostMapping(produces = {"application/json;charset=UTF-8"})
	public AjaxResult save(@RequestBody CourseFile courseFile) {
		return AjaxResult.success(courseFileService.save(courseFile));
	}

	/**
	 * 通过id删除课程文件
	 *
	 * @param id /
	 * @return R
	 */
	@ApiOperation(value = "通过id删除课程文件")
	@DeleteMapping(value = "/{id}", produces = {"application/json;charset=UTF-8"})
	public AjaxResult removeById(@PathVariable Long id) {
		return AjaxResult.success(courseFileService.removeById(id));
	}
}
